<!DOCTYPE html>
<html lang="en">
<head>
    <title>员工修改个人登录密码$</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/laypage.css">
    <link rel="stylesheet" href="/layui-util/css/layui.css" media="all">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/layui-util/layui.js" charset="utf-8"></script>
    <script src="/js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <script src="/js/jquery.validation/1.14.0/messages_zh.min.js"></script>
    <script src="/js/vue/vue.min.js"></script>
    <script src="/js/layer/layer.js" charset="utf-8"></script>
    <style>
        select.error, input.error {
            border: 1px solid red;
        }
    </style>
</head>
<body>
<section id="container">
<#include "sider.ftl">
    <section id="main-content">
        <section class="wrapper">
            <div class="table-agile-info">
                <div class="panel panel-default">
                    <section class="panel" style="width: 350px;margin: 0 auto">
                        <header class="panel-heading">
                            <h3>我的信息设置</h3>
                        </header>
                        <div class="panel-body">
                            <div class="form" id="app">
                                <form class="cmxform form-horizontal" id="updateEmpForm">
                                    <input type="hidden" value="${emp.euuId}" id="euuId" name="euuId">
                                    <div class="form-group ">
                                        <label for="empName" class="control-label col-lg-3"></label>
                                        <div class="col-lg-6">
                                            <input class=" form-control" id="empName" name="empName" type="hidden"
                                                   value="${emp.empName}" autocomplete="off">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="empPassword" class="control-label col-lg-3">新密码</label>
                                        <div class="col-lg-6">
                                            <input class=" form-control" id="empPassword" name="empPassword"
                                                   type="password">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="empPassword" class="control-label col-lg-3">确认新密码</label>
                                        <div class="col-lg-6">
                                            <input class=" form-control" id="empPassword1" name="empPassword1"
                                                   type="password">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="empPhone" class="control-label col-lg-3">电话</label>
                                        <div class="col-lg-6">
                                            <input class=" form-control" id="empPhone" name="empPhone" type="text"
                                                   value="${emp.empPhone}" autocomplete="off">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="empAddress" class="control-label col-lg-3">现住地址</label>
                                        <div class="col-lg-6">
                                            <input class=" form-control" id="empAddress" name="empAddress" type="text"
                                                   value="${emp.empAddress}" autocomplete="off">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-lg-offset-3 col-lg-6">
                                            <button class="btn btn-primary" type="button" id="referBut">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </section>
    <#include "/foot.html">
    </section>
</section>
</body>
</html>
<script>
    /*点击事件*/
    var updateEmp = function () {
        if (!check().form()) {
            return;
        }
        $.ajax({
            url: "/emp/toUpEmpPs.do",
            type: "post",
            data: $("#updateEmpForm").serialize(),
            success: function () {
                alert("密码已修改,请重新登录");
                layer.open(window.location = "/login.html");
            }
        });
    };
    var check = function () {
        jQuery.validator.addMethod("regex", function (value, element, params) {
            var exp = new RegExp(params);
            return exp.test(value);
        }, "格式错误");
        return $("#updateEmpForm").validate({
            rules: {
                empPhone: {
                    required: true,
                    regex: "^(((13[0-9]{1})|(15[0-9]{1}))+\\d{8})$"
                },
                empAddress: {
                    required: true
                },
                empPassword: {
                    required: true,
                    rangelength: [3, 11]
                },
                empPassword1: {
                    required: true,
                    equalTo: "#empPassword"
                }
            },
            messages: {
                empPhone: {
                    required: "",
                    regex: "手机号格式不正确"
                },
                empAddress: {
                    required: ""
                },
                empPassword: {
                    required: "",
                    rangelength: "用户名长度为3-11之间"
                },
                empPassword1: {
                    required: "",
                    equalTo: "两次密码不一致"
                }
            }
        });
    };
    $("#referBut").click(function () {
        $("#referBut").submit();//button按钮变为submit
        updateEmp();
    });
    $("#updateEmpForm").click(function () {
        if (!check().form()) {
            return;
        }
    });
</script>

